/**
 * @author Mie Plougstrup, Anders Abildgaard, Bo Stokholm 
 * @Version 16-12-2014
 */
package tests;

import static org.junit.Assert.*;

import java.sql.Date;

import modelLayer.Disposition;
import modelLayer.DispositionList;

import org.junit.Test;

import ctrLayer.CtrBooking;
import ctrLayer.CtrDisposition;
import dbLayer.DbMaxId;

public class TestCtrDisposition {
	CtrDisposition ctrDisp = new CtrDisposition();
	CtrBooking ctrBooking = new CtrBooking();

	@Test
	public void testCreateDispList() {
		Date shipping = new Date(10, 07, 2015);
		try{
			ctrDisp.createDispList(shipping);
			DispositionList dl = ctrDisp.retrieveDispList(DbMaxId.getMaxID("dispositionList", "dispListId"), true);
			Date shipDate = dl.getShippingDate();
			
			if(shipDate.getDate() == shipping.getDate())
				System.out.println("DispList created successfully");
			else
				fail("cant create displist");
		}catch(Exception e){
			fail("Failed to create disp list.");
		}
		
		//Insert dispo
		try{
			ctrDisp.addDisposition(ctrDisp.retrieveDispList(1, false), 8261, 1, 1, "38184-4");
		}catch(Exception e){
			fail("Failed to add disposition");
		}
		
		//Add booking
		try{
			ctrDisp.addBooking(ctrDisp.retrieveDisp(1), ctrBooking.retrieveBooking(2));
		}catch(Exception e){
			fail("Failed to add booking.");
		}
		
		//retrieve the displist we have created earlier
		
		
		//End disp list
		try{
			ctrDisp.endDispList(ctrDisp.retrieveDispList(1, true));
		}catch(Exception e){
			fail("Failed to end dispList");
		}
	}
}
